<!DOCTYPE HTML>
<html>
<head>
<include file="Include:meta" />
<title>前期沟通-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text"><if condition="$project['info_id'] neq NULL">商务跟进</if>项目 > [{$project['project_num']}]{$project['project_name']} > 前期沟通</div>
	</div>
	<div id="content">
		<include file="Include:project_header" />
		<form method="post" name="number_validate" id="password_validate" novalidate="novalidate">
			<div class="form-main">
				<div class="form-title">前期沟通</div>
				<div class="form-table-item">
					<table class="table">
						<tbody>
							<tr class="form-table-header">
								<td width="18%">日期</td>
								<td width="18%">工作类别</td>
								<td width="18%">备注</td>
								<td width="18%">资料预览</td>
								<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
								<if condition="$project['gt_status'] neq 1">
								<td width="5%">管理</td>
								</if>
								</if>
							</tr>
							<if condition="$result eq NULL">
							<tr>
								<td class="text-center" <if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1) and ($project['gt_status'] neq 1)">colspan="5"<else/>colspan="4"</if>>暂无相关数据</td>
							</tr>
							</if>
							<foreach name="result" item="vo">
								<tr>
									<td>{$vo['date']}</td>
									<td>{$vo['work_type']}</td>
									<td>{$vo['remark']}</td>
									<td><if condition="$vo['file_url'] neq NULL">{$vo['file_name']}<a href="{$vo['file_url']}" class="ml5" data-toggle="tooltip" data-placement="right" title="下载"><i class="glyphicon glyphicon-download-alt"></i></a></if></td>
									<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
									<if condition="$project['gt_status'] neq 1">
									<td><a href="javascript:;" mid="{$vo['id']}" action="communicate_delete" data-toggle="tooltip" data-placement="left" title="删除" class="delete ml5"><i class="glyphicon glyphicon-trash"></i></a></td>
									</if>
									</if>
								</tr>
							</foreach>
						</tbody>
					</table>
				</div>
				<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
				<if condition="$project['gt_status'] neq 1">
				<div class="form-title">考察/商务洽谈前信息录入</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>日期</div>
					<div class="input-item">
						<input type="text" name="date" class="form-control Wdate w100 required-text" onclick="WdatePicker()" readonly autocomplete="off">
						<span class="error-item">必填项</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>工作类别</div>
					<div class="input-item">
						<span class="checkbox-item">
							<label class="radio-inline"><input type="radio" name="work_type" value="电话沟通">电话沟通</label>
							<label class="radio-inline"><input type="radio" name="work_type" value="发送资料">发送资料</label>
							<label class="radio-inline"><input type="radio" name="work_type" value="接收资料">接收资料</label>
							<label class="radio-inline"><input type="radio" name="work_type" value="商务简报">商务简报</label>
							<label class="radio-inline"><input type="radio" name="work_type" value="邮件沟通">邮件沟通</label>
							<span class="error-item">必填项</span>
						</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">备注</div>
					<div class="input-item">
						<div>
							【发送资料】
							<label class="checkbox-inline"><input type="checkbox" name="remark[]" value="公司宣传册">公司宣传册</label>
							<label class="checkbox-inline"><input type="checkbox" name="remark[]" value="项目案例">项目案例</label>
							<label class="checkbox-inline"><input type="checkbox" name="remark[]" value="报价函">报价函</label>
							<label class="checkbox-inline"><input type="checkbox" name="remark[]" value="人员简历">人员简历</label>
							<label class="checkbox-inline"><input type="checkbox" name="remark[]" value="工作计划书">工作计划书</label>
							<label class="checkbox-inline"><input type="checkbox" name="remark[]" value="合同">合同</label>
						</div>
						<div>
							【接收资料】
							<label class="checkbox-inline"><input type="checkbox" name="remark[]" value="项目基地资料">项目基地资料</label>
							<label class="checkbox-inline"><input type="checkbox" name="remark[]" value="企业客户资料">企业客户资料</label>
							<label class="checkbox-inline"><input type="checkbox" name="remark[]" value="相关研究成果">相关研究成果</label>
						</div>
						<div>
							【其它备注】
							<label class="checkbox-inline"><input type="checkbox" name="other" value="其它">其它</label>
							<input type="text" name="remark_text" class="form-control ml10 hide">
							<span class="error-item">必填项</span>
						</div>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">上传相关资料</div>
					<div class="input-item">
						<div class="input-group w250 left">
							<input type="text" name="file_name" class="form-control file-name" placeholder="请上传附件" readonly autocomplete="off">
							<span class="input-group-btn">
								<button class="btn file-submit" type="button">上传</button>
							</span>
						</div>
						<button class="btn file-delete ml5 hide" type="button">删除</button>
						<input type="hidden" name="file_url" class="file-url" autocomplete="off">
						<span class="error-item">文件名必填</span>
					</div>
				</div>
				<div class="form-btn-item"><button class="btn submit" type="button">提交</button></div>
				</if>
			</div>
			<if condition="($project['gt_status'] eq NULL) or ($project['gt_status'] eq -1)">
				<div class="form-btn-item"><button class="btn jd_up" pid="{$project['id']}" action="gt_status" status="1" type="button">阶段完成</button></div>
			<elseif condition="($project['gt_status'] eq 1) and (($project['tp_status'] eq -1) or ($project['tp_status'] eq NULL))"/>
				<div class="form-btn-item"><button class="btn jd_down" pid="{$project['id']}" action="gt_status" status="-1" type="button">放弃完成</button></div>
			</if>
			</if>
		</form>
	</div>
</div>
<include file="Include:javascript" />
<script>
$(function(){
	$(".delete").ajaxModal({"title_text":"删除提示框","body_text":"您确定要删除吗？","url":"__APP__/Project/stage_ajax","data":{"id":"mid","action":"action"}});
	$(".jd_up").ajaxModal({"title_text":"完成提示框","body_text":"您确定要完成该阶段吗？","url":"__APP__/Project/stage_ajax","data":{"id":"pid","action":"action","status":"status"}});
	$(".jd_down").ajaxModal({"title_text":"放弃提示框","body_text":"您确定要放弃该阶段吗？","url":"__APP__/Project/stage_ajax","data":{"id":"pid","action":"action","status":"status"}});
	KindEditor.ready(function(K){
		//上传附件
		var editorFile = K.editor();
		$('.file-submit').on('click',function(){
			var parents = $(this).parents(".input-group");
			editorFile.loadPlugin('insertfile',function(){
				document.cookie="file_name=communicate";
				document.cookie="file_type=ppt,pptx,pdf,doc,docx,jpg,jpeg,png,xls,xlsx,txt,rar,zip";
				editorFile.plugin.fileDialog({
					clickFn:function(url,title){
						parents.nextAll(".error-item").hide();
						parents.find(".file-name").val(title).prop("readonly",false);
						parents.nextAll(".file-url").val(url);
						parents.nextAll(".file-delete").show();
						editorFile.hideDialog();
					}
				});
			});
		});
	});
	//删除附件
	$(".file-delete").click(function(){
		$(this).hide();
		$(this).nextAll(".error-item").hide();
		$(this).nextAll(".file-url").val("");
		$(this).prevAll(".input-group").find(".file-name").val("").prop("readonly",true);
		$(this).parents("tr").find(".required-text2").next(".error-item").hide();
	});
	//其它勾选效果
	$("[name='other']").click(function(){
		var $text = $(this).parent().next("[name='remark_text']");
		if($(this).prop("checked")){
			$text.show();
		}else{
			$text.hide().val("");
			$text.next(".error-item").hide();
		}
	});
	//提交验证
	$(".submit").on('click',function(){
		var tag = true;
		$(".required-text").each(function(){
			var $val = $(this).val();
			if($val==""){
				$(this).nextAll(".error-item").show();
				tag = false;
			}
		});
		$("[name='remark_text']").each(function(){
			if($(this).is(":visible") && $(this).val()==""){
				$(this).next(".error-item").show();
				tag = false;
			}
		});
		if($("[name='work_type']:checked").length==0){
			$("[name='work_type']").parent().siblings(".error-item").show();
			tag = false;
		}
		$(".file-name").each(function(){
			var val = $(this).val();
			if((val=="" || /^\s+$/.test(val)) && !$(this).prop("readonly")){
				$(this).parents(".input-group").nextAll(".error-item").show();
				tag = false;
			}
		});
		$(".file-url").each(function(){
			var val = $(this).val();
			if(val!=""){
				$(this).parents("tr").find(".required-text2").each(function(){
					var val2 = $(this).val();
					if(val2=="" || /^\s+$/.test(val2)){
						$(this).next(".error-item").show();
						tag = false;
					}
				});
			}
		});
		if(tag){
			var communicate_add = 'communicate_add',
				pid = "{$project['id']}";
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:$("[name='number_validate']").serialize()+"&action="+communicate_add+"&pid="+pid,
				url:"__APP__/Project/stage_ajax",
				success:function(data){
					success_pop(data.status,data.msg);
				}
			});    
		}
	});
	//隐藏错误提示
	$(".required-text,[name='remark_text']").focus(function(){
		$(this).nextAll(".error-item").hide();
	});
	$("[name='work_type']").click(function(){
		$(this).parent().siblings(".error-item").hide();
	});
	$(".file-name").on("focus",function(){
		$(this).parents(".input-group").nextAll(".error-item").hide();
	});
})
</script>
</body>
</html>